app.controller("companyTaxCertificateController", function ($scope, $controller, $location, companyService, $http) {

    $controller('baseController', {$scope: $scope});
    $scope.taxCertificateList = []
    $scope.companyTaxcertificate = {brandId: 19}


    $scope.findPage = function (pageNum, pageSize) {

        if (pageNum == null) pageNum = 1;

        if (pageSize == null) pageSize = 10;

        if (companyName != null) $scope.companyTaxcertificate.companyName = companyName;

        if (yearMonth != null) $scope.companyTaxcertificate.yearMonth = yearMonth;

        companyService.findCompanyTaxCertificateList(pageNum, pageSize, $scope.companyTaxcertificate).success(function (response) {

            if (response.code == 200) {
                //获取企业完税证明列表
                $scope.taxCertificateList = response.data;
            }
        })
    }

    $scope.addCompanyTaxCertificate = function () {
        let forData = new FormData();
        const uploadsFile = document.getElementById(`file_um`);
        const company_um = document.getElementById(`companyName_um`).value;
        const yearMonth_um = document.getElementById(`yearMonth_um`).value;
        forData.append("file", uploadsFile.files[0]);
        forData.append("companyName", company_um);
        forData.append("yearMonth", yearMonth_um);
        forData.append("brandId", "19");
        $http({
            method: 'POST',
            url: '/tanhaogongManager/company/addCompanyTaxCertificate',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        }).success(function (response) {
            console.log(response)
            if (response.code === 200) {
                uploadsFile.outerHTML = uploadsFile.outerHTML
                document.getElementById(`companyName_um`).value = ''
                document.getElementById(`yearMonth_um`).value = ''
                alert("上传成功")
                $scope.findPage(1,10);
            } else {
                alert(response.msg)
            }
        })
    };

});